﻿using NHibernate;

namespace Myotragus.Data
{
	public class SessionFactoryAdapter : ISessionFactoryAdapter
	{
		public ISessionFactory Factory { get; set; }

		public ISessionFactoryAdapter SetFactory(ISessionFactory factory)
		{
			Factory = factory;
			return this;
		}

		private ISession _session;

		public ISession OpenSession()
		{
			return _session ?? (_session = Factory.OpenSession());
		}
	}
}